package com.sugar.service.oa.hr;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sugar.base.query.PageModel;
import com.sugar.domain.oa.hr.Department;
import com.sugar.persistence.oa.hr.IDepartment;

@Service
public class DepartmentServiceBean implements IDepartmentService{
	
	@Resource
	private IDepartment deptdao ;

	@Override
	public void deleteDeptService(String id) throws RuntimeException {
		
		this.deptdao.deleteDeptDao(this.loadDeptByIdService(id)) ;
	}

	@Override
	public List<Department> findDeptService(Object[] param)
			throws RuntimeException {
		
		String queryString = "select o from Department o" ;
		
		return this.deptdao.findDeptDao(queryString, null, param, null) ;
		
	}

	@Override
	public PageModel<Department> getScorllDeptService(Object[] param,
			int firstPage, int pageSize) throws RuntimeException {
		
		String queryString = "select o from Department o" ;
		
		return this.deptdao.getScorllDeptDao(queryString, null, param, firstPage, pageSize, null);
	}

	@Override
	public Department loadDeptByIdService(String id) throws RuntimeException {
		
		return this.deptdao.loadDeptByIdDao(id) ;
	}

	@Override
	public void saveDeptService(Department dept) throws RuntimeException {
		//dept.setDeptNo("SG-BM-"+RandomUtil.getRandomNum(6)) ;
		this.deptdao.saveDeptDao(dept) ;
	}

	@Override
	public void updateDeptService(Department Dept) throws RuntimeException {
		this.deptdao.updateDeptDao(Dept) ;
	}

	@Override
	public void deleteSelectDeptService(Object[] ids) throws RuntimeException {
		this.deptdao.deleteSelectDeptDao(ids) ;
	}

}
